package com.leyou.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.item.entity.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BrandMapper extends BaseMapper<Brand> {

    @Select("select tb.* from tb_brand tb, tb_category_brand tcb where tb.id = tcb.brand_id and tcb.category_id = #{id}")
    List<Brand> queryBrandsByCategoryId(@Param("id") Long id);

    @Insert("insert into tb_category_brand values(#{categoryId},#{id})")
    void addBrandAndCategory(@Param("categoryId") String categoryId, @Param("id") Long id);

    @Delete("delete from tb_category_brand where brand_id = #{id}")
    void delBrandAndCategoryByBrandId(@Param("id") Long id);
}
